#ifndef wm_actions_h
#define wm_actions_h
/*
 * Sylvain BERTRAND <digital.ragnarok@gmail.com>
 * code protected by GNU GPL v3
 */
struct wm_actions_data {
	enum wm_user_action uact;
	guint state;
	gint x;
	gint y;
	gint button;
	struct wm_client *client;
	enum wm_frame_context context;
};
typedef void (*wm_actions_data_free_func)(gpointer options);
typedef gboolean (*wm_actions_run_func)(struct wm_actions_data * data, gpointer options);
typedef gpointer (*wm_actions_data_setup_func)(xmlNodePtr node);
typedef void (*wm_actions_shutdown_func)(void);
typedef gboolean (*wm_actions_i_pre_func)(guint initial_state, gpointer options);
typedef void (*wm_actions_i_post_func)(gpointer options);
typedef gboolean (*wm_actions_i_input_func)(guint initial_state, XEvent *e, struct t_ic * ic, gpointer options,
	gboolean *used);
typedef void (*wm_actions_i_cancel_func)(gpointer options);
typedef gpointer (*wm_actions_i_data_setup_func)(xmlNodePtr node, wm_actions_i_pre_func *pre,
	wm_actions_i_input_func *input, wm_actions_i_cancel_func *cancel, wm_actions_i_post_func *post);
struct wm_actions_definition {
	guint ref;
	gchar *name;
	gboolean canbeinteractive;
	union {
		wm_actions_i_data_setup_func i;
		wm_actions_data_setup_func n;
	} setup;
	wm_actions_data_free_func free;
	wm_actions_run_func run;
	wm_actions_shutdown_func shutdown;
};
struct wm_actions_act {
	guint ref;
	struct wm_actions_definition *def;
	wm_actions_i_pre_func i_pre;
	wm_actions_i_input_func i_input;
	wm_actions_i_cancel_func i_cancel;
	wm_actions_i_post_func i_post;
	gpointer options;
};
void actions_startup();
void actions_shutdown();
gboolean actions_register_i(const gchar *name, wm_actions_i_data_setup_func setup, wm_actions_data_free_func free,
	wm_actions_run_func run);
gboolean actions_register(const gchar *name, wm_actions_data_setup_func setup, wm_actions_data_free_func free,
	wm_actions_run_func run);
struct wm_actions_act *actions_parse(xmlNodePtr node);
struct wm_actions_act *actions_parse_string(const gchar *name);
gboolean actions_act_is_interactive(struct wm_actions_act *act);
void actions_act_unref(struct wm_actions_act *act);
void actions_run_acts(GSList *acts, enum wm_user_action uact, guint state, gint x, gint y, gint button,
	enum wm_frame_context con, struct wm_client *client);
gboolean actions_interactive_act_running(void);
void actions_interactive_cancel_act(void);
gboolean actions_interactive_input_event(XEvent *e);
void actions_client_move(struct wm_actions_data *data, gboolean start);
#endif
